package org.lib.jpamysql.query;

import java.util.Collection;
import java.util.List;

import org.lib.jpamysql.query.projections.FullNameOnly;
import org.lib.jpamysql.query.projections.NameOnly;
import org.lib.jpamysql.query.projections.UserSimpleVO;
import org.lib.jpamysql.query.projections.UserSummary;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

/**
 * 查询结果处理：projections
 * @author ben
 * @date 2021-10-30 09:22:33 CST
 */
@Repository(value = "user2Dao")
public interface User2DAO extends JpaRepository<User, Long> {

	// projections
	
	List<NameOnly> findByLastName(String lastName);
	
	// Distinct
	List<NameOnly> findDistinctByLastName(String lastName);
	
	List<UserSummary> findByAge(int age);
	
	List<FullNameOnly> findFirstByAge(int age);
	
	List<UserSimpleVO> findByAgeGreaterThan(int age);
	
	// 动态projections
	
	<T> Collection<T> findByLastName(String lastName, Class<T> type);
	
}
